package Reflex.获取类名;

import Reflex.类.Student;

public class GetClass {
    /**
     * 获取类名的三种方式
     * @param args
     */
    public static void main(String[] args) {
        //类.class
        Class stuClass1 = Student.class;
        System.out.println(stuClass1);

        //对象.getClass()
        Student student = new Student();
        Class stuClass2 = student.getClass();
        System.out.println(stuClass2);

        //Class.forName("类的全名")
        Class stuClass3 = null;
        try {
            stuClass3 = Class.forName("Reflex.类.Student");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        System.out.println(stuClass3);

        System.out.println(stuClass1 == stuClass2);
        System.out.println(stuClass2 == stuClass3);
    }
}
